package org.four.user.mapper;

import org.apache.ibatis.annotations.*;
import org.four.common.model.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

    //树
    @Select("select * from t_user_tree where pid=#{value}")
    List<NavBean> queryTrees(Integer id);

    //查询一条
    @Select("select * from t_user where account=#{value}")
    UserBean testAccount(String account);

    //注册
    @Insert("insert into t_user(account,password) values(#{account},#{password})")
    void saveUser(UserBean userBean);

    //登陆
    @Select("select * from t_user where account=#{value}")
    UserBean queryUserByAccount(String account);

    //新增简历
    @Insert("insert into t_user_qiuzhi(workname, workingplace,wage,hangye,qiuzhidate,pingjia,worktype) values(#{workname},#{workingplace},#{wage},#{hangye},#{qiuzhidate},#{pingjia},#{worktype})")
    void addUser(ZhiweiBean zhiweiBean);

    //修改简历
    @Update("update t_user_qiuzhi set workname=#{workname},workingplace=#{workingplace},wage=#{wage},hangye=#{hangye},qiuzhidate=#{qiuzhidate},pingjia=#{pingjia},worktype=#{worktype} where id = #{id}")
    void upda(ProductBean productBean);

    //个人中心分页查询商品
    @Select("select count(1) from t_user_qiuzhi where userid = #{value}")
    int queryProductCount(Integer id);

    //个人中心分页查询商品
    @Select("select * from t_user_qiuzhi where userid = #{id}  limit #{st},#{limit}")
    List<ProductBean> queryProduct(@RequestParam("st") int st, @RequestParam("limit") int limit,@RequestParam("id") Integer id);

    //简历回显
    @Select("select * from t_user_qiuzhi where id=#{value}")
    ProductBean findProductInfo(Integer id);

    //查询投递
    @Select("select count(1)" +
            " from t_user_toudi tut  " +
            " left join t_com_zhaopin tcz on tcz.id = tut.gangweiid " +
            " where tut.userid = #{value}")
    int querytoucount(Integer id);

    //查询投递
    @Select("select tut.toudistatus,tcz.title,tcz.xinzi,tcz.fabudate,tcz.worktype,tcz.yaoqiu,tcz.zhiweitype,tcz.miaoshu,tcz.touch " +
            ",tcz.tel,tcz.email,tcz.comname,tcz.daiyuid " +
            " from t_user_toudi tut  " +
            " left join t_com_zhaopin tcz on tcz.id = tut.gangweiid " +
            " where tut.userid = #{id} limit #{st},#{limit}")
    List<ZhaoPinBean> querytoudi(@RequestParam("st")int st,@RequestParam("limit") int limit,@RequestParam("id") Integer id);

    //个人中心分页查询商品
    /*@Select("      select count(1) from t_user a\n" +
            "      left join  t_user_gongzuo b on a.id=b.userid\n" +
            "      left join  t_user_jingyan c on a.id=c.userid\n" +
            "      left join  t_user_qiuzhi  d on a.id=d.userid\n" +
            "      left join  t_user_status  e on a.id=e.userid\n" +
            "      left join  t_user_techang f on a.id=f.userid\n" +
            "      left join  t_user_xuexiao g on a.id=g.userid")
    int queryProductCountcjq1();


							  left join  t_user_gongzuo b on a.id=b.userid
                  left join  t_user_jingyan c on a.id=c.userid
                  left join  t_user_qiuzhi  d on a.id=d.userid
                 left join  t_user_status  e on a.id=e.userid
                  left join  t_user_techang f on a.id=f.userid
                 left join  t_user_xuexiao g on a.id=g.userid

    */

    //个人中心分页查询商品
    @Select(" select * from   t_user  where id = #{value} ")
    List<UserBean> queryProductcjq1(Integer id);

    //收藏分页查询商品
    @Select("select count(1) from t_user_qiuzhi a " +
            "left join t_user b on a.userid=b.id  left join t_user_gongzuo c on a.userid=c.userid   where a.status=2")
    int queryProductCount2();

    //收藏分页查询商品
    @Select("select * from t_user_qiuzhi a " +
            "left join t_user b on a.userid=b.id     left join t_user_gongzuo c on a.userid=c.userid     where a.status=2 limit #{st},#{limit}")
    List<ZhiweiBean> queryzhiwei(@Param("st") int st, @Param("limit") int limit);

    //订阅分页查询商品
    int queryProductCount3(@Param("zhiweiBean") ZhiweiBean zhiweiBean);

    //订阅分页查询商品
    List<ZhiweiBean> queryzhiwei3(@Param("st") int st, @Param("limit") int limit, @Param("zhiweiBean") ZhiweiBean zhiweiBean);

    //删除收藏
    void delcjq(Integer[] id);

    //删除订阅
    void del2(Integer[] id);

    //新增订阅
    @Insert("insert into t_user_qiuzhi(workname, workingplace, wage,hangye,email,status) values(#{workname},#{workingplace},#{wage},#{hangye},#{email},1)")
    void addProductcjq(ZhiweiBean zhiweiBean);

    //修改订阅
    @Update("update t_user_qiuzhi set workname=#{workname},workingplace=#{workingplace},wage=#{wage},hangye=#{hangye},email=#{email} where id = #{id}")
    void updacjq(ZhiweiBean zhiweiBean);

    //账号设置
    @Update("update t_user set account=#{account} where id={id}")
    void zhanggai(UserBean userBean);

    //账号设置查询
    @Select("select count(1) from t_user")
    int haolistcount();

    //账号设置查询
    @Select("select account from t_user limit #{st},#{limit}")
    List<UserBean> haolist(int st, int limit);

    //测试
    Integer queryCount(@Param("zhaoPinBean") ZhaoPinBean zhaoPinBean);

    //测试
    List<ZhaoPinBean> queryList(@Param("start") Integer start, @Param("end") Integer end, @Param("zhaoPinBean") ZhaoPinBean zhaoPinBean);

    //测试 精确查询
    @Select("select * from t_com_user ")
    List<ComUserBean> queryType();

    //查询招聘的岗位
    @Select("select * from t_com_zhaopin ")
    List<ZhaoPinBean> findZhaoPin();

    //跳转
     @Select("select a.id,a.title,a.xinzi,a.comid, b.comname from t_com_zhaopin a left join t_com_user b on  a.comid=b.id")
    List<ZhaoPinBean> findProductListImg();

    //根据id查询商品详情
    @Select("select a.title,a.xinzi,a.daiyuid,a.miaoshu,a.tel, b.comname ,a.worknian,a.yaoqiu from t_com_zhaopin a left join t_com_user b on  a.comid=b.id where a.id=#{value}")
    List<Map> queryProductById(Integer id);

    //订阅回显
    @Select("select * from t_user_qiuzhi where id=#{value}")
    ZhiweiBean findyue(Integer id);

    //投递简历
    @Insert("insert into t_user_toudi (userid,comid,gangweiid,jianliid,toudistatus) values(#{userid},#{comid},#{gangweiid},#{jianliid},#{toudistatus},1)")
    void addli(ToudiBean toudiBean);

    @Update("update t_user_qiuzhi set status=2 where id = #{id}")
    void productState(Integer id);

    @Select("select * from t_user_jingyan where userid = #{value}")
    List<JingYanBean> JingYanBean(Integer id);

    @Insert("insert into t_user_jingyan(comname,hangyetype,projectname,miaoshu,userid) value(#{comname},#{hangyetype},#{projectname},#{miaoshu},#{userid})")
    void addXiangmu(JingYanBean jingYanBean);

    @Delete("delete from t_user_jingyan where id = #{value}")
    void delXiangMu(Integer id);

    @Insert("insert into t_user_toudi(comid,userid) values(#{comid},#{userid})")
    void addtoudi(@Param("comid")Integer comid,@Param("userid") Integer userid);


    //修改用户登录密码
    @Update("update t_user set password = #{md532} where id = #{id}")
    void updatePassWord(@Param("id") Integer id, @Param("md532")String md532);

    //根据userId 查询具体的数据
    @Select(" select tu.id,tu.account,tu.truename,DATE_FORMAT(tu.roendate,'%Y-%m-%d %H:%i:%S') as roendate,DATE_FORMAT(tu.startworkdate,'%Y-%m-%d %H:%i:%S') as startworkdate , "+
            " tu.sex,tu.tel,tu.address,tu.haiwai,tu.gouzuo,tug.comname as comnamegong ,tug.hangyetype as hangyetypegong ,tug.workname,tug.zhiyetype, " +
            " DATE_FORMAT(tug.workdate,'%Y-%m-%d %H:%i:%S') as workdate,tug.salary,tug.pingjia,tuj.comname,tuj.hangyetype,tuj.projectname,tuj.miaoshu, " +
            " tut.skills,tut.chengdu from t_user tu  "+
                 " left join t_user_gongzuo tug on tug.userid = tu.id " +
                 " left join t_user_jingyan tuj on tuj.userid = tu.id " +
                 " left join t_user_techang tut on tut.userid = tu.id " +
            " where tu.id = #{value} ")
    UserBean findQueryUserList(Integer id);

    /**
     * 工作经历表
     * @param id
     * @return
     */
    @Select("select id ,comname,hangyetype,workname,zhiyetype,DATE_FORMAT(workdate,'%Y-%m-%d %H:%i:%S') as workdate,salary,pingjia from t_user_gongzuo")
    List<GongZuoBean> findUserGongZuoJingLi(Integer id);
    //删除教育经历
    @Delete("delete from t_user_gongzuo where id = #{value}")
    void delGongZuo(Integer id);
    //新增教育经历
    @Insert("insert into t_user_gongzuo(comname,hangyetype,workname,zhiyetype,workdate,salary,pingjia,userid) " +
            "values(#{comname},#{hangyetype},#{workname},#{zhiyetype},#{workdate},#{salary},#{pingjia},#{userid})")
    void saveGongZuo(GongZuoBean gongZuoBean);

    //教育查询
    @Select("select * from t_user_xuexiao where userid = #{value}")
    List<JiaoYuBen> findConypanyMessage(Integer id);

    //删除教育经历
    @Delete("delete from t_user_xuexiao where id = #{value}")
    void delJiaoYu(Integer id);

    //新增教育经历
    @Insert("insert into t_user_xuexiao(createTime,endTime,schoolName,xueLi,tongZhao,professional,userId) " +
            "values(#{createTime},#{endTime},#{schoolName},#{xueLi},#{tongZhao},#{professional},#{userId})")
    void saveJiaoYu(JiaoYuBen jiaoYuBen);
    @Select("select a.cominfo,a.comid,a.address,a.comguimo,a.licheng,c.comname,c.username,c.zhizhao from t_com_ziliao a left join t_com_zhaopin b on a.comid=b.id left join t_com_user c on a.comid=c.id  ")
    List<Map> queryjituan(Integer comid);

}
